var solrmgr;
var Manager;
dojo.declare("Main", wm.Page, {
"preferredDevice": "desktop",
start: function() {
this.initializeAjaxSolrManager();
},
initializeAjaxSolrManager: function() {
console.log("Starting the start function", this);
Manager = new AjaxSolr.Manager({
//proxyUrl: 'solr/'
solrUrl: '/solr/'
});
solrmgr = Manager;
console.log("calling Manager.init");
Manager.init();
Manager.addWidget(new AjaxSolr.ResultWidget({
id: 'result',
target: 'solr-results'
}));
Manager.addWidget(new AjaxSolr.PagerWidget({
id: 'pager',
target: 'solr-pager',
//            prevLabel: '&lt;',
//            nextLabel: '&gt;',
innerWindow: 1,
renderHeader: function (perPage, offset, total) {
//Remove Jquery Dependency
//$('#pager-header').html($('<span/>').text('displaying ' + Math.min(total, offset + 1) + ' to ' + Math.min(total, offset + perPage) + ' of ' + total));
//                var text = 'displaying ' + Math.min(total, offset + 1) + ' to ' + Math.min(total, offset + perPage) + ' of ' + total;
//                dojo.html.set(dojo.byId('pager-header'),'<span>'+text+'</span>',{parseContent : true});
dojo.html.set(dojo.byId('pager-header').innerHTML = '<span> | Displaying ' + Math.min(total, offset + 1) + ' to ' + Math.min(total, offset + perPage) + ' of ' + total+'</span>');
}
}));
},
buttonSolrSearchClick: function(inSender) {
console.log("Building basic solr query");
/*
These things are now unnecessary as these parameters are set as part of the $.ajax call in the app script
Manager.store.remove('fq'); // Remove any previous filters and clear filter cache so that the entire data set is being searched
Manager.store.addByValue('q', '*:*'); // Set the query to all
Manager.store.addByValue('fq', this.textSearchBox.getValue("dataValue")); // set the query filter based on the text input from the user
Manager.store.addByValue('rows', this.textMaxSearchResults.getValue("dataValue")); // set the maximum number of results to return based on the input from the user
*/
console.log("Attempting to talk to solr");
Manager.doRequest();
console.log("Response", Manager.response);
console.log("Completed the start function");
},
_end: 0
});

Main.widgets = {
layoutBox1: ["wm.Layout", {"horizontalAlign":"center","styles":{"backgroundColor":"#ffffff"},"verticalAlign":"top"}, {}, {
panel3: ["wm.Panel", {"height":"100%","horizontalAlign":"center","verticalAlign":"top","width":"100%"}, {}, {
label2Panel: ["wm.Panel", {"height":"40px","horizontalAlign":"left","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
label2: ["wm.Panel", {"height":"40px","horizontalAlign":"center","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
label3: ["wm.Label", {"caption":"Ajax-Solr Integration Testing App","height":"40px","padding":"4","styles":{"fontSize":"36px","fontFamily":"Geneva"},"width":"490px"}, {}]
}]
}],
label1Panel: ["wm.Panel", {"height":"40px","horizontalAlign":"center","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
label1: ["wm.Label", {"caption":"Information on Solr Query Syntax can be found here:","height":"34px","padding":"4","styles":{"fontSize":"16px","fontFamily":"Geneva"},"width":"327px"}, {}],
label4: ["wm.Label", {"caption":"http://wiki.apache.org/solr/SolrQuerySyntax","height":"34px","link":"http://wiki.apache.org/solr/SolrQuerySyntax","padding":"4","styles":{"fontSize":"14px","fontFamily":"Geneva"},"width":"279px"}, {}]
}],
panel1: ["wm.Panel", {"height":"24px","horizontalAlign":"center","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
textMaxSearchResults: ["wm.Text", {"caption":"Max.Search Results","captionSize":"150px","dataValue":undefined,"displayValue":"","width":"223px"}, {}],
label5: ["wm.Label", {"caption":"(Default is 10)","padding":"4","styles":{"fontWeight":"bold"},"width":"192px"}, {}]
}],
text1Panel: ["wm.Panel", {"height":"26px","horizontalAlign":"center","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
textSearchBox: ["wm.Text", {"caption":undefined,"dataValue":undefined,"displayValue":""}, {"onEnterKeyPress":"buttonSolrSearchClick"}],
buttonSolrSearch: ["wm.Button", {"caption":"Search","desktopHeight":"26px","height":"26px","margin":"4"}, {"onclick":"buttonSolrSearchClick"}]
}],
panel2: ["wm.Panel", {"height":"24px","horizontalAlign":"center","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
textNumberOfSearchResults: ["wm.Text", {"caption":"Number of Results","captionSize":"150px","dataValue":undefined,"displayValue":"","width":"223px"}, {}],
label6: ["wm.Label", {"caption":"","padding":"4","styles":{"fontWeight":"bold"},"width":"192px"}, {}]
}],
htmlPagerHeaderPanel: ["wm.Panel", {"height":"30px","horizontalAlign":"left","layoutKind":"left-to-right","verticalAlign":"top","width":"75%"}, {}, {
htmlPagerHeader: ["wm.Html", {"height":"100%","html":"<div id=\"solr-pager\"></div>\n<div id=\"pager-header\"></div>","minDesktopHeight":15}, {}]
}],
html1: ["wm.Html", {"height":"100%","html":"<div id=\"solr-results\"></div>","minDesktopHeight":15,"width":"75%"}, {}]
}]
}]
};

Main.prototype._cssText = '#solr-pager {\
display: inline;\
}\
#pager-header {\
display: inline;\
}\
#solr-pager li,\
.links li {\
list-style-type: none;\
display: inline;\
}\
';
Main.prototype._htmlText = '';